//
//  LJUITabBar.m
//  TheDragon
//
//  Created by appleLJ on 2017/6/30.
//  Copyright © 2017年 LJ. All rights reserved.
//

#import "LJUITabBar.h"
@interface LJUITabBar()
/// 当前选中的位置
@property (nonatomic, assign) NSInteger selectIndex;
@property (nonatomic, strong) NSMutableArray *itemsArr;
@end
@implementation LJUITabBar

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
    }
    return self;
}

- (void)setDataArray:(NSMutableArray *)dataArray{
    _dataArray = dataArray;
    _itemsArr = @[].mutableCopy;
    for (int i = 0; i < _dataArray.count; i++) {
        UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:_dataArray[i][@"title"] image:[UIImage imageNamed:_dataArray[i][@"img"]] tag:2000+i];
        [_itemsArr addObject:item];
    }
    [self setItems:_itemsArr];
}
- (void)setSelectIndex:(NSInteger)selectIndex
{
    // 先把上次选择的item设置为可用
    UIButton *lastItem = _itemsArr[_selectIndex];
    lastItem.enabled = YES;
    // 再把这次选择的item设置为不可用
    UIButton *item = _itemsArr[selectIndex];
    item.enabled = NO;
    _selectIndex = selectIndex;
}
- (void)reload:(int) collectState{
    _selectIndex = 2;

//    for(UITabBarItem *item in _itemsArr){
//        if([item.title isEqualToString:@"收藏"]){
//            if(collectState == 0){
//                _selectIndex = -1;
//            }
//            else{
//                _selectIndex = 0;
//            }
//        }
//        else{
//            _selectIndex = -1;
//        }
//        
//    }
    
}

//重写，去掉选中效果
//- (void)setSelectedItem:(UITabBarItem *)selectedItem{
//}


@end
